package com.sxdz.controller.service.account

import com.sxdz.controller.mapper.TWxAccountMapper
import com.sxdz.controller.service.BaseService
import com.sxdz.models.TWxAccount
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
/**
 * Created by LiYan on 2016/8/1.
 */
@Service
@CompileStatic
@TypeChecked
class AccountService extends BaseService implements IAccountService{

    private TWxAccountMapper tWxAccountMapper;

    @Autowired
    private setTWxAccountMapper(TWxAccountMapper tWxAccountMapper){
        this.tWxAccountMapper=tWxAccountMapper;
        super.baseMapper=tWxAccountMapper;
    }

    @Override
    @Transactional
    Long addBasic(def obj) throws Exception {
        TWxAccount tWxAccount=obj as TWxAccount
        tWxAccount.createTime = new Date().getTime();
        tWxAccount.updateTime = tWxAccount.createTime
        tWxAccountMapper.insertSelective(tWxAccount)
        return tWxAccount.id
    }

    @Override
    @Transactional
    void modifyBasic(def obj) throws Exception {
        TWxAccount tWxAccount=obj as TWxAccount
        tWxAccount.updateTime = tWxAccount.createTime
        tWxAccountMapper.updateByPrimaryKeySelective(tWxAccount)
    }

    @Override
    @Transactional
    void delBasic(def obj) throws Exception {
        TWxAccount tWxAccount=obj as TWxAccount
        def id=tWxAccount.id
        tWxAccountMapper.deleteByPrimaryKey(id)
    }

    @Override
    int deleteAcc(Long id) {
        return tWxAccountMapper.deleteByPrimaryKey(id);
    }

    List<TWxAccount> findListByParams(Map<String,Object> param){
        return tWxAccountMapper.selectListByParams(param,null,null,null)
    }

    TWxAccount findObj(Map<String,Object> param){
        return tWxAccountMapper.selectByParams(param)
    }

    @Override
    Long selectByPrimaryKey(Long id) {
        return null;
        //tWxAccountMapper.selectByPrimaryKey(id);
    }
}
